<?php
        define("GRID_SOURCE", "");
        
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.
        
        session_start();
	require_once "../funciones.php";
       
        //Define identifying name(s) to your grid(s). Must be unqiue name(s).
        $grid_id = array("grid");

        //Remember to comment the again line when publishing PHP Grid, or else PHP Grid wont remember the settings between page loads.
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
        
?>
<html>
        <head>
                <title>Fisico4</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css">
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
				<script>
                        function validar(e,serial)
                        {
                            var tecla7;
                        
                            if (document.all) { tecla7 = e.keyCode;  }
                            else {  tecla7 = e.which; }
                            if (tecla7 == 13) { location.href="adiciona_fisico4.php?serial="+serial;  }
                            else { return false; }
                        }
				</script>
                </head>
                <body onload="document.getElementById('Editbox1').focus();">
	<?php

	if ($_SESSION['caweb']['iniciar'] == 1)
	{
	?>
		Interno :<input type="text" id="Editbox1" onkeypress="validar(event,this.value);" size="15" name="Editbox1" value="" />
                <?php
			$bodegaactualitem=$_SESSION['caweb']['bodegaactualitem'];
			$sucursalactualitem=$_SESSION['caweb']['sucursalactualitem'];
			echo  "Ultimo Interno ".$_SESSION['caweb']['ultimointerno'];
		 	if ($_SESSION['caweb']['resultado'] == 1) { echo "<font color=green><b> CORRECTO </b></font>"; }
			if ($_SESSION['caweb']['resultado'] == 2) { echo "<font color=black><b> Sin datos </b></font>"; }
                        if ($_SESSION['caweb']['resultado'] == 3) { echo "<font color=red><b> INTERNO EN TRANSACCION ACTUAL </b></font>"; }

			$username=$_SESSION['caweb']['username'];
			$sucursal=$_SESSION['caweb']['sucursal'];
			$bodega=$_SESSION['caweb']['bodega'];

			$condicion="usuariocreo='$username' AND sucursal='$sucursal' AND bodega='$bodega'";

			$canttod=$_SESSION['caweb']['canttod'];
			$cantcpu=$_SESSION['caweb']['cantcpu'];
			$cantmon=$_SESSION['caweb']['cantmon'];
			$cantimp=$_SESSION['caweb']['cantimp'];
			$cantotr=$_SESSION['caweb']['cantotr'];

			$link_caweb = con_caweb();
			$result58 ="SELECT * FROM temporal_fisico4 WHERE $condicion";
			$result58=mysql_query($result58,$link_caweb) or die('Error temporal_fisico4, '.mysql_error());
			$llevatod=mysql_num_rows($result58);

			$result58 ="SELECT * FROM temporal_fisico4 WHERE $condicion AND LEFT(item,1)='C'";
                        $result58=mysql_query($result58,$link_caweb) or die('Error temporal_fisico4, '.mysql_error());
                        $llevacpu=mysql_num_rows($result58);

			$result58 ="SELECT * FROM temporal_fisico4 WHERE $condicion AND LEFT(item,1)='M'";
                        $result58=mysql_query($result58,$link_caweb) or die('Error temporal_fisico4, '.mysql_error());
                        $llevamon=mysql_num_rows($result58);

			$result58 ="SELECT * FROM temporal_fisico4 WHERE $condicion AND LEFT(item,1)='I'";
                        $result58=mysql_query($result58,$link_caweb) or die('Error temporal_fisico4, '.mysql_error());
                        $llevaimp=mysql_num_rows($result58);

			$result58 ="SELECT * FROM temporal_fisico4 WHERE $condicion AND LEFT(item,1)='O'";
                        $result58=mysql_query($result58,$link_caweb) or die('Error temporal_fisico4, '.mysql_error());
                        $llevaotr=mysql_num_rows($result58);

			echo "<br><table border=1><tr>
				    <td> Todos <td> Cpu <td> Mon <td> Imp <td> Otro </td></tr>
				<tr><td> $llevatod - ".round(($llevatod*100/$canttod),1).
				   "%<td> $llevacpu - ".round(($llevacpu*100/$cantcpu),1).
				   "%<td> $llevamon - ".round(($llevamon*100/$cantmon),1).
				   "%<td> $llevaimp - ".round(($llevaimp*100/$cantimp),1).
				   "%<td> $llevaotr - ".round(($llevaotr*100/$cantotr),1)."%</tr></table>";

            $_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");
			$_SESSION["grid"]->SetSqlSelect('id,interno,item', 'temporal_fisico4',$condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", true);
			$_SESSION["grid"]->SetTitleName("Interno para Inventario Fisico");
			$_SESSION["grid"]->SetEditModeEdit(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(15);
       	    $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("interno", true);
			$_SESSION["grid"]->SetDatabaseColumnEditable("item", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
	}
                ?>



        </body> 
</html>
